-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: add global or import scripts into DOM #1030
base: main
Are you sure you want to change the base?
Conversation
Visit the preview URL for this PR (updated for commit cc73007): https://react-kitchen-sink-dev--pr1030-1027-add-global-and-mit9l9lq.web.app (expires Tue, 25 Feb 2025 18:52:03 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: 6267897ade2ba783b6db70a53a60fc3946d625e9 |
|
${importedScripts || ""} | ||
${globalBlock || ""} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to wrap this in a function that will be unique by screen. When the script loads, it should execute this function that returns a closure object with a function to eval, with an expression and context.
It should look like this
// script tag content, rename unique by screen
const createEvalClosure = () => {
// importedScripts
// globalScripts
return (expression, context) => {
// evalCode
}
}
const evalInClosure = createEvalClosure()
// elsewhere
evalInClosure(expression, context)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You will still need to define ensemble in the window.
Describe your changes
Add global or import scripts into DOM to reduce the load on buildEvaluateFunction
Screenshots [Optional]
Issue ticket number and link
Closes #1027
Checklist before requesting a review
pnpm changeset add